package mushystuff.dtb.web.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import mushystuff.dtb.core.model.Product;
import mushystuff.dtb.core.service.ProductService;

import org.springframework.web.bind.annotation.ModelAttribute;

public abstract class BaseController {
        
    @Resource
    protected ProductService productService;
    
    @ModelAttribute("productSelectorList")
    public List<Product> getProductSelectorList() {
        return productService.getAllActiveProducts();
    }
    
    public Product getCurrentProduct(HttpSession session) {
        return productService.getProduct((Long)session.getAttribute("productId"));
    }
    
}
